<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="">
    <meta http-equiv="x-dns-prefetch-control" content="on">

    <title>抢单列表</title>
    <link href="../../css/css.css" rel="stylesheet" type="text/css">
    <script src="../../js/jquery-v1.11.2.min.js"></script>
    <script src="../../js/driver.js"></script>
    <script src="../../js/common.js"></script>
</head>
<body>
<section id="bid_list_section">
    <section class="itemgroup mt10">
        <div class="order_title">
            订单编号: <label class="type ml5">APP</label>
            <label class="right gray">明日 15:30</label>
        </div>
        <div class="photoitem ml15 font14">
            <i class="iconfont mr5 green icon20">&#xe70d;</i>

        </div>
        <div class="photoitem ml15 font14">
            <i class="iconfont mr5 red icon20">&#xe70c;</i>

        </div>
        <div class="oneitem p15">
            <label class="gray font12">特殊要求:</label>
        </div>
        <div class="orderitem p15 lh40 font14">
            费用:<label class="red">￥</label>
            <button class="btn right orderbtn"></button>
        </div>
    </section>
</section>
<script type="text/javascript">
    $(function () {
        //token验证
        checkDriverToken();
    });

    var array1 = new Array();
    var array2 = new Array();
    $(document).ready(function () {
        //首页-跳抢单列表
        var url = _global.serverHost + "/driver/bid_list.htm";
        var driverUuid=getCookie("driverUuid");
        var data = {"driverUuid":driverUuid};
        _callAjaxRequest(url, data, bidBack);

        function bidBack(data) {
            var bidList = data.bidList;
            var bid_list_section = "";
            if (bidList.length <= 0) {
                bid_list_section = '<section class="itemgroup mt10" style="text-align: center">没有更多的抢单信息</section>';
            } else {
                for (var i = 0; i < bidList.length; i++) {
                    var waybillSource = "";
                    if (bidList[i].waybillSource == '10') {
                        waybillSource = "<label class='type ml5'>APP</label>";
                    } else if (bidList[i].waybillSource == '20') {
                        waybillSource = "<label class='type ml5'>网站</label>";
                    } else if (bidList[i].waybillSource == '30') {
                        waybillSource = "<label class='type ml5'>客服电话</label>";
                    } else if (bidList[i].waybillSource == '40') {
                        waybillSource = "<label class='type ml5'>微信</label>";
                    }
                    var require = "";
                    if (bidList[i].requireList.length > 0) {
                        require = '<div class="oneitem p15">'
                                + '<label class="gray font12">特殊要求:</label>';
                        for (var j = 0; j < bidList[i].requireList.length; j++) {
                            require = require + '<div class="comments_type right';
                            if (j > 0) {
                                require = require + ' mr5';
                            }
                            require = require + '">' + bidList[i].requireList[j].requirementName + '</div>';
                        }
                        require = require + '</div>';
                    }
                    bid_list_section = bid_list_section + '<section class="itemgroup mt10" onclick="goDetail(\'' + bidList[i].waybillId + '\')">' +
                            '<div class="order_title">'
                            + '订单编号: ' + bidList[i].waybillNum
                            + waybillSource + '<label class="right gray">' + bidList[i].bookDateDesc + '</label>'
                            + '</div>'
                            + '<div class="photoitem ml15 font14">'
                            + '<i class="iconfont mr5 green icon20">&#xe70d;</i>'
                            + (bidList[i].startDistrict+bidList[i].startStreet)
                            + '</div>'
                            + '<div class="photoitem ml15 font14">'
                            + '<i class="iconfont mr5 red icon20">&#xe70c;</i>'
                            + (bidList[i].endDistrict+bidList[i].endStreet)
                            + '</div>'
                            + require
                            + '<div class="orderitem p15 lh40 font14">'
                            + '费用:<label class="red">￥' + bidList[i].planTotalFee + '</label>'
                            + '<button type="button" class="btn right orderbtn" >'
                            + '<span class="countdown" id="Countdown_' + bidList[i].waybillId + '" '
                            + 'data-k="' + bidList[i].waybillId + '" data-i="' + bidList[i].seconds + '">已结束</span>'
                            + '</button>'
                            + '</div></section>';

                    array1.push(bidList[i].seconds);//秒数
                    array2.push(bidList[i].waybillId);//id
                }
            }
            $("#bid_list_section").html(bid_list_section);
        }


    });

    function goDetail(waybillId) {
        window.location.href = "../bid/bid_detail.html?waybillId=" + waybillId;
    }

    function time_start() {
        for (var len = array2.length, j = 0; j < len; j++) {//能不能一一对应起来，再说
            if (array1[j] > 0) {
                var arrayj1 = array1[j];
                countdown(array1[j], array2[j]);//传剩余时间，id
                array1[j] = parseInt(arrayj1) - 1;//将剩余时间减一
            }
        }
    }

    setInterval("time_start()", 1000);
    function countdown(timer, id) {
//    && timer <= 20
        if (timer > 1) {
            $("#Countdown_" + id).html("抢(" + timer + "s)");
        }
        if (timer <=0){
            $("#Countdown_" + id).html("已结束");
        }
    }

    //    });
</script>
</body>
</html>